(function(){
	define("lib/checkForm",[],function(){
		function u(e,t){
			if(t===0){
				e.removeClass(o),
				e.text(r),
				clearTimeout(timer());
				return}
			timer=setTimeout(function(){
				e.text(t-- +s),
				u(e,t)},1e3)}
		var e=/^1[3|4|5|7|8][0-9]\d{8}$/,
		t=/^\d{4}$/,
		n=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/,
		r="发送验证码",
		s="秒后重新获取",
		o="disabled";
		mobile_errors={
				mobile_verificated:"该手机已注册，请直接登录",
				parameter_error:"请输入正确的11位手机号码",
				mobile_exists:"该手机已注册，请直接登录",
				unknow:"获取验证码失败，请重新获取"},
				getError="获取验证码失败，请重新获取",
$.fn.check=function(r,i,s,o){
			var r=r||"此项",
			s=s||0,
			o=o||Infinity,
			u=this.val(),a=u.length,
			f=this.parents(".form-item").find(".form-error"),
			l=this.parents("form").find(".form-error");
			l.empty();
			if(i.contains("required"))
				if(u==null||$.trim(u)=="")
					return f.html("请填写"+r),
			!1;
			if(i.contains("range")&&a>0)if(a<s||a>o)return s==0?f.html(r+"最多"+o+"字"):o==Infinity?f.html(r+"最少"+s+"字"):f.html(r+"须在"+s+" ~ "+o+"个字之间"),
!1;
			if(i.contains("num")){u-=0;if(u==null||u=="")return f.html("请填写"+r),
			!1;
if(isNaN(u))
	return f.html(r+"请填写数字"),
!1}
if(i.contains("mobile")){
if(u==null||u=="")
	return f.html("请填写"+r),
	!1;
if(!e.test(u))
	return f.html("请填写正确的11位"+r),
!1}

if(i.contains("password")){
	if(u==null||u=="")
		return f.html("请填写"+r),
!1;
	if(u.length<6||u.length>20)
		return f.html(r+"长度须大于6且小于20"),
		!1;
		
		}
var pw=$("input[type=password]").val();
var uu=$("#identity").val();
if(i.contains("mobile")){
	$.ajax({
		url:"login?user.userName="+uu+"&user.password="+pw,
		data:u,
		type:"post",
		dataType:"json",
			success:function(data){
				if(data == 3){
					alert('登录成功！');
					
					window.location.href="index";
				}
				if(data == 1){
					alert('用户名或者密码错误，请重新登录！');
					document.dbform.action=""; 
					return false;
				}
				if(data == 4){
					alert('用户名或者密码错误，请重新登录！');
					return false;
				}
			return ;
			
}})
	!1}
if(i.contains("code")){
	if(u==null||u=="")return f.html("请填写"+r),!1;
if(!t.test(u))
	return f.html("请填写正确的"+r),!1}
if(i.contains("email")){
if(u==null||u=="")
	return f.html("请填写"+r),!1;
if(!n.test(u))
return f.html("请填写正确的"+r),!1}
return!0},
$.fn.checkRequired=function(e){
var e=e||"此项",
t=this.val(),
n=this.parents(".form-item").find(".form-error"),
r=this.parents("form").find(".form-error");
return r.empty(),
t==null||$.trim(t)==""?(n.html("请填写"+e),!1):!0},
$.fn.checkRange=function(e,t,n){
	var e=e||"此项",t=t||0,n=n||Infinity,r=this.val(),i=r.length,
s=this.parents(".form-item").find(".form-error"),
o=this.parents("form").find(".form-error");
	return o.empty(),
i<t||i>n?(t==0?s.html(e+"最多"+n+"字"):n==Infinity?s.html(e+"最少"+t+"字"):s.html(e+"须在"+t+" ~ "+n+"个字之间"),
	!1):!0},
	$.fn.checkNum=function(e){var e=e||"此项",t=t-0,
		n=this.parents(".form-item").find(".form-error"),
		r=this.parents("form").find(".form-error");
	r.empty();if(t==null||t=="")return n.html("请填写"+e),!1;
	if(isNaN(t))return n.html(e+"请填写数字"),!1},
	$.fn.checkMobile=function(t){
		var t=t||"手机号",
		n=this.val(),
		r=this.parents(".form-item").find(".form-error"),
		i=this.parents("form").find(".form-error");
	return i.empty(),n==null||n==""?(r.html("请填写"+t),
			!1):e.test(n)?!0:(r.html("请填写正确的11位"+t),!1)},
			$.fn.checkPassword=function(e){
				var e=e||"密码",
				t=this.val(),
				n=this.parents(".form-item").find(".form-error"),
				r=this.parents("form").find(".form-error");return r.empty(),
				t==null||t==""?(n.html("请填写"+e),!1):t.length<6||t.length>20?(n.html(e+"长度须大于6且小于20"),!1):!0},
				$.fn.checkCode=function(e){var e=e||"验证码",n=this.val(),
					r=this.parents(".form-item").find(".form-error"),
					i=this.parents("form").find(".form-error");return i.empty(),
					n==null||n==""?(r.html("请填写"+e),!1):t.test(n)?!0:(r.html("请填写正确的"+e),!1)},
					$.fn.checkEmail=function(e){var e=e||"邮箱",t=this.val(),
						r=this.parents(".form-item").find(".form-error"),
						i=this.parents("form").find(".form-error");
					return i.empty(),t==null||t==""?(r.html("请填写"+e),!1):n.test(t)?!0:(r.html("请填写正确的"+e),!1)},
$.fn.getCode=function(e,t,n){this.click(function(i){
						i.preventDefault();
						var a=$(this),
					f=e.parents(".form-item").find(".form-error");
						
						if(a.hasClass(o)||!e.checkMobile())return
						!1;
						a.addClass(o),
						a.text(n-- +s),
						u(a,n),
					$.ajax({
						url:t+"?mobile="+JSON.stringify(e.val()),
						data:JSON.stringify({mobile:e.val()}),
						type:"post",
						dataType:"json",
							success:function(data){
								$(data).each(function (i, obj) {
									var status=obj.code;
									if(status=="mobile_already_exists"){
										 clearTimeout(timer),
										 f.text(mobile_errors.mobile_verificated),
										 a.removeClass(o),
								            a.text(r)
									}
					            });
		}})})},
Array.prototype.contains=function(e){for(i=0;i<this.length;i++)
	if(this[i]==e)return!0;return!1}}),require(["lib/checkForm"],function(e){
		"use strict";function c(e){var t=$(".checkbox"),n=e,r=!!n.attr("checked"),
			i=r?"checkbox-true":"checkbox-false";t.addClass(i),n.click(function(){
				t.hasClass("checkbox-true")?t.removeClass("checkbox-true").addClass("checkbox-false"):t.removeClass("checkbox-false").addClass("checkbox-true")})}
		var t=navigator.userAgent.toLowerCase(),n=t.match(/MicroMessenger/i)=="micromessenger";
		n&&$(".signup-panel .login-weixin").attr("href",weixin_mp_login_url).css("display","block");
		var r=$("#mobile"),i=$("#code"),s=$("#nickname"),o=$("input[type=password]"),u=$("#identity"),
		a=$("#readme"),f=$(".getCode"),l=$("#submit");
		f.getCode(r,"sendMobileSms",60),
		l.click(function(){
			if(page_name==="login")
			return u.check("手机号",["required","mobile"])&&o.check("密码",["required"]);
			
		if(page_name==="signup")
			return a.is(":checked")?r.check("手机号",["required","mobile"])&&i.check("验证码",["required","code"])&&s.check("昵称",["required","range"],2,10)&&o.check("密码",["required","password"]):(alert("请阅读并勾选同意《服务条款》选项"),!1)}),
		$("#phoneBtn").click(function(){$("#phoneLogin .signForm:visible").length||$("#phoneLogin .signForm").slideDown()}),c(a)}),
		define("signup",function(){})})();